package gotoDemo;

/**
 * description :
 * author Ahang :
 * create : 2025-10-10 10:01
 */
public class GOToTest {

    public static void main(String[] args) {
        System.out.println("演示类似goto的标签使用:");

        outer: for (int i = 1; i <= 3; i++) {
            System.out.println("外层循环 i = " + i);

            inner: for (int j = 1; j <= 3; j++) {
                System.out.println("  内层循环 j = " + j);

                if (i == 2 && j == 2) {
                    System.out.println("  >> 满足条件，跳出所有循环");
                    break outer; // 类似goto，直接跳出到outer标签处
                }

                if (j == 2) {
                    System.out.println("  >> j=2，继续外层循环");
                    continue outer; // 类似goto，跳到outer的下一次迭代
                }
            }
        }

        System.out.println("循环结束");
    }
}
